package com.aiti.lulian.controller;

import cn.hutool.core.util.StrUtil;
import com.aiti.base.core.utils.message.Message;
import com.aiti.lulian.dto.ClickDto;
import com.aiti.lulian.service.IClickService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "点击量控制层")
@RestController
@RequestMapping("/click")
public class ClickController {

    @Autowired
    private IClickService clickService;

    @ApiOperation("增加点击量")
    @PutMapping("/increase")
    public Message increaseClick(@RequestBody ClickDto dto) {
        if (StrUtil.isBlank(dto.getModule())) {
            return Message.fail("未选择模块");
        }
        if (StrUtil.isBlank(dto.getId())) {
            return Message.fail("id不能为空");
        }
        clickService.increaseClick(dto);
        return Message.success();
    }
}
